import React from 'react';
import { useNavigate } from 'react-router-dom'
import { Form, Input, Button, Checkbox } from 'antd';
import { UserOutlined, LockOutlined } from '@ant-design/icons';
import { setToken } from '@/utils/session'
import './SignIn.less';

const SignIn = () => {
  const navigate = useNavigate()
  const onFinish = () => {
    setToken('token')
    setTimeout(() => {
      navigate('/home')
    }, 1000)
  };

  return (
    <Form
      className="signin-form"
      onFinish={onFinish}
      initialValues={{ remember: false }}
      labelCol={{ span: 24 }}
    >
      <Form.Item
        name="username"
        label="用户名"
        required={false}
      >
        <Input
          prefix={<UserOutlined />}
          placeholder="请输入用户名"
          style={{ height: 40 }}
        />
      </Form.Item>
      <Form.Item
        name="password"
        label="密码"
        required={false}
      >
        <Input
          prefix={<LockOutlined />}
          type="password"
          placeholder="请输入密码"
          style={{ height: 40 }}
        />
      </Form.Item>

      <div className="remerber-wrap">
        <Form.Item name="remember" valuePropName="checked">
          <Checkbox>记住密码</Checkbox>
        </Form.Item>
        <a className="forgot" href="">
          忘记密码？
        </a>
      </div>

      <Form.Item>
        <Button type="primary" size="large" htmlType="submit" block>
          登录
        </Button>
      </Form.Item>
    </Form>
  );
};

export default SignIn;
